<?php
  class Bo_suu_tap extends Media_Controller{
      public function __construct(){
          parent :: __construct();
          $this->load->model('Media_m');
      }
      
      function index(){
          $this->albums();
      }
      
      function albums(){
        $this->_data['page_title'] = "Albums";
        $per_page = $this->uri->segment(3);
        if ($per_page == "") {
            $per_page = 8;
        }
        $off_set = $this->uri->segment(4);
        if ($off_set == "") {
            $off_set = 0;
        }
        /*$config['full_tag_open'] = "<div id='wrapperpage'>";
        $config['full_tag_close'] = '</div>';
        $config['cur_tag_open'] = '<span id="pageactive"> ';
        $config['cur_tag_close'] = ' </span>';*/
        $config['next_link'] = 'Suiv.';
        $config['prev_link'] = 'Prec.';
        $config['base_url'] = base_url() . 'index.php/Bo_suu_tap/albums/' . $per_page . '/';
        $config['per_page'] = $per_page;
        $config['uri_segment'] = 4;
        $config['total_rows'] = $this->Media_m->count_photo_albums();
        if ($off_set > 0 && $off_set == $config['total_rows']) {
            $off_set = $off_set - $per_page;
        }
        $this->_data['album_data'] = $this->Media_m->get_photo_albums($config['per_page'], $off_set);
        $this->pagination->initialize($config);
        $this->_data['pagination'] = $this->pagination->create_links();
        $this->_data['perpage'] = $per_page;
        $this->_data['offset'] = $off_set;
        
        
        $this->display_view('home/gallerie/album');
      }
      
      function album($id){
      	
        $this->_data['list_photo_album'] = $this->Media_m->list_photo_by_album($id);
       
        $this->_data['page_title'] = "Ảnh album";
        
        $this->display_view('home/gallerie/album_details');	
      }
      
      function album_cua_bo_suu_tap($cat_id){
        $this->_data['page_title'] = "Albums cua bo suu tap";
        $per_page = $this->uri->segment(4);
        if ($per_page == "") {
            $per_page = 8;
        }
        $off_set = $this->uri->segment(5);
        if ($off_set == "") {
            $off_set = 0;
        }
        /*$config['full_tag_open'] = "<div id='wrapperpage'>";
        $config['full_tag_close'] = '</div>';
        $config['cur_tag_open'] = '<span id="pageactive"> ';
        $config['cur_tag_close'] = ' </span>';*/
        $config['next_link'] = 'Suiv.';
        $config['prev_link'] = 'Prec.';
        $config['base_url'] = base_url() . 'index.php/Bo_suu_tap/album_cua_bo_suu_tap/' ."/".$cat_id."/". $per_page . '/';
        $config['per_page'] = $per_page;
        $config['uri_segment'] = 5;
        $config['total_rows'] = $this->Media_m->count_all_album_by_category($cat_id);
        if ($off_set > 0 && $off_set == $config['total_rows']) {
            $off_set = $off_set - $per_page;
        }
        $this->_data['album_data'] = $this->Media_m->get_all_album_by_category($cat_id, $config['per_page'], $off_set);
        $this->pagination->initialize($config);
        $this->_data['pagination'] = $this->pagination->create_links();
        $this->_data['perpage'] = $per_page;
        $this->_data['offset'] = $off_set;
        
        
        $this->display_view('home/gallerie/album');
      }
      
      function anh_cua_album($id){
          $data['images'] = $this->Media_m->get_image_of_album($id);
          $data['album'] = $this->Media_m->get_name_of_album($id);
          $this->load->view('home/gallerie/view_album_images', $data);
      }
      
      
      
  
  }
?>
